/**
 * Copyright 2009 Adam Ruggles.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.code.sapien.dao;

import java.io.Serializable;

/**
 * Interface for basic data operations on entity data models.
 * @author Adam
 * @version $Id: EntityDAO.java 11 2009-03-27 06:33:32Z a.ruggles $
 * 
 * Created on Feb 7, 2009 at 5:38:32 PM
 * @param <T> The entity type.
 */
public interface EntityDAO<T> {
    /**
     * Adds an entity.
     * @param entity The entity to add.
     */
    void add(T entity);
    /**
     * Returns an entity by the id.
     * @param id The id of the object.
     * @return The entity with the given id or <code>null</code> if not found. 
     */
    T get(Serializable id);
    /**
     * Returns an entity by the id, whose state may be in a lazy state.
     * @param id The id of the object.
     * @return The entity with the given id.
     */
    T load(Serializable id);
    /**
     * Removes an entity.
     * @param entity The entity to remove.
     */
    void remove(T entity);
    /**
     * Updates an entity.
     * @param entity The entity to update.
     * @return an updated persistent instance.
     */
    T update(T entity);
}
